package com.github.jspxnet.worktask.service;



import com.github.jspxnet.worktask.model.dto.ProcessResponse;
import com.github.jspxnet.worktask.model.param.WorkTaskParam;
import com.github.jspxnet.worktask.table.WorkTask;

import java.util.List;
import java.util.Map;

/**
 * Created by jspx.net
 *
 * author: chenYuan
 * date: 2020/9/12 23:56
 * description: 各种启动方式
 *
 * 任务分配时，依据流程定义。首先依据人工活动定义的Assignee,直接进行分配，假设 Assignee有值，此时该任务处于已认领状态。
 * 然后继续运行任务的候选人分配，候选人分两种：候选组表达式及候选人表达式，解析表达式。进行公共任务分配。
 * * 任务应该没有状态，标记是已经被认领时，是依据该任务的属性：task.getAssignee()是否有值进行推断
 *
 *
 * Activiti之任务完毕
 *在创建一个新人工任务时。在数据表IdentityLinkEntity中删除当前已完毕的这条数据，当流程实例结束时。删除execution表中的当前流程数据。
 **/
public interface RuntimeService {
    /**
     *
     * @param workTaskParam 流程参数
     * @return 启动一个流程
     */
    ProcessResponse<?> start(WorkTaskParam workTaskParam);
    /**
     * @param workTaskParam 节点动作
     * @param variables     变量
     * @return 返回状态
     */
    ProcessResponse<?> start(WorkTaskParam workTaskParam, Map<String, Object> variables);
    /**
     * @param workTaskParam 变量
     * @return 得到用户当前的代办任务列表
     */
    List<String> getDocumentList(WorkTaskParam workTaskParam, int currentPage, int count);

    List<WorkTask> getCurrentWorkTask(WorkTaskParam workTaskParam);

    List<WorkTask> getCurrentDocumentWorkTask(WorkTaskParam workTaskParam);

    ProcessResponse<?> complete(WorkTaskParam workTaskParam);

    ProcessResponse<?> complete(WorkTaskParam workTaskParam, Map<String, Object> variables);

    ProcessResponse<?> singleResult(WorkTaskParam workTaskParam);

    int deleteDocumentTask(WorkTaskParam workTaskParam);


/**
     * Starts a new process instance in the latest version of the process definition with the given key.
     *
     * A business key can be provided to associate the process instance with a certain identifier that has a clear business meaning. For example in an order process, the business key could be an order
     * id. This business key can then be used to easily look up that process instance , see {@link ProcessInstanceQuery#processInstanceBusinessKey(String)}. Providing such a business key is definitely a
     * best practice.
     *
     * The combination of processdefinitionKey-businessKey must be unique.
     *
     * @param flowNo
     *          key of process definition, cannot be null.
     * @param variables
     *          the variables to pass, can be null.
     * @param businessKey
     *         定义一个 businessKey 来启动
     * @throws ActivitiObjectNotFoundException
     *           when no process definition is deployed with the given key.
     *//*

    ProcessInstance startProcessInstance(String flowNo, String businessKey, Map<String, Object> variables);

    */
/**
     * Starts a new process instance in the exactly specified version of the process definition with the given id.
     *
     * @param flowId    the id of the process definition, cannot be null.
     * @throws ActivitiObjectNotFoundException
     *           when no process definition is deployed with the given key.
     *//*

    ProcessInstance startProcessInstance(long flowId);

    */
/**
     * Starts a new process instance in the exactly specified version of the process definition with the given id.
     *
     * A business key can be provided to associate the process instance with a certain identifier that has a clear business meaning. For example in an order process, the business key could be an order
     * id. This business key can then be used to easily look up that process instance , see {@link ProcessInstanceQuery#processInstanceBusinessKey(String)}. Providing such a business key is definitely a
     * best practice.
     *
     * @param flowId
     *          the id of the process definition, cannot be null.
     * @param businessKey
     *          a key that uniquely identifies the process instance in the context or the given process definition.
     * @throws ActivitiObjectNotFoundException
     *           when no process definition is deployed with the given key.
     *//*

    ProcessInstance startProcessInstance(long flowId, String businessKey);

    */
/**
     * Starts a new process instance in the exactly specified version of the process definition with the given id.
     *
     * @param flowId
     *          the id of the process definition, cannot be null.
     * @param variables
     *          variables to be passed, can be null
     * @throws ActivitiObjectNotFoundException
     *           when no process definition is deployed with the given key.
     *//*

    ProcessInstance startProcessInstance(long flowId, Map<String, Object> variables);

    */
/**
     * Starts a new process instance in the exactly specified version of the process definition with the given id.
     *
     * A business key can be provided to associate the process instance with a certain identifier that has a clear business meaning. For example in an order process, the business key could be an order
     * id. This business key can then be used to easily look up that process instance , see {@link ProcessInstanceQuery#processInstanceBusinessKey(String)}. Providing such a business key is definitely a
     * best practice.
     *
     * @param flowId
     *          the id of the process definition, cannot be null.
     * @param variables
     *          variables to be passed, can be null
     * @throws ActivitiObjectNotFoundException
     *           when no process definition is deployed with the given key.
     *//*

    ProcessInstance startProcessInstance(long flowId, String businessKey, Map<String, Object> variables);

    */
/**
     * Delete an existing runtime process instance.
     * 删除现有的运行时流程实例。
     * @param flowId
     *          id of process instance to delete, cannot be null.
     * @param deleteReason
     *          reason for deleting, can be null.
     * @throws ActivitiObjectNotFoundException     when no process instance is found with the given id. 采用级联删除
     *//*

    void deleteProcessInstance(long flowId, String deleteReason);

    */
/**
     * Finds the activity ids for all executions that are waiting in activities. This is a list because a single activity can be active multiple times.
     * 查找在活动中等待的所有执行的活动id。
     * @param executionId     id of the execution, cannot be null.
     * @throws ActivitiObjectNotFoundException
     *           when no execution exists with the given executionId.
     *//*

    List<String> getActiveActivityIds(String executionId);

    */
/**
     * Sends an external trigger to an activity instance that is waiting inside the given execution.
     *
     * @param executionId
     *          id of execution to signal, cannot be null.
     * @throws ActivitiObjectNotFoundException
     *           when no execution is found for the given executionId.
     *//*

    void trigger(String executionId);

    */
/**
     * Sends an external trigger to an activity instance that is waiting inside the given execution.
     *
     * @param executionId
     *          id of execution to signal, cannot be null.
     * @param processVariables
     *          a map of process variables
     * @throws ActivitiObjectNotFoundException
     *           when no execution is found for the given executionId.
     *//*

    void trigger(String executionId, Map<String, Object> processVariables);


    */
/**
     * Similar to {@link #trigger(String, Map)}, but with an extra parameter that allows to pass
     * transient variables.
     *//*

    void trigger(String executionId, Map<String, Object> processVariables, Map<String, Object> transientVariables);

    */
/**
     * Updates the business key for the provided process instance
     *
     * @param flowId
     *          id of the process instance to set the business key, cannot be null
     * @param businessKey
     *          new businessKey value
     *//*

    void updateBusinessKey(long flowId, String businessKey);

    // Identity Links
    // ///////////////////////////////////////////////////////////////

    */
/**
     * Involves a user with a process instance. The type of identity link is defined by the given identityLinkType.
     *
     * @param flowId
     *          id of the process instance, cannot be null.
     * @param userId
     *          id of the user involve, cannot be null.
     * @param identityLinkType
     *          type of identityLink, cannot be null (@see {@link IdentityLinkType}).
     * @throws ActivitiObjectNotFoundException
     *           when the process instance doesn't exist.
     *//*

    void addUserIdentityLink(long flowId, String userId, String identityLinkType);

    */
/**
     * Involves a group with a process instance. The type of identityLink is defined by the given identityLink.
     *
     * @param flowId
     *          id of the process instance, cannot be null.
     * @param groupId
     *          id of the group to involve, cannot be null.
     * @param identityLinkType
     *          type of identity, cannot be null (@see {@link IdentityLinkType}).
     * @throws ActivitiObjectNotFoundException
     *           when the process instance or group doesn't exist.
     *//*

    void addGroupIdentityLink(long flowId, String groupId, String identityLinkType);

    */
/**
     * Convenience shorthand for {@link #addUserIdentityLink(String, String, String)}; with type {@link IdentityLinkType#CANDIDATE}
     *
     * @param flowId
     *          id of the process instance, cannot be null.
     * @param userId
     *          id of the user to use as candidate, cannot be null.
     * @throws ActivitiObjectNotFoundException
     *           when the task or user doesn't exist.
     *//*

    void addParticipantUser(long flowId, String userId);

    */
/**
     * Convenience shorthand for {@link #addGroupIdentityLink(String, String, String)}; with type {@link IdentityLinkType#CANDIDATE}
     *
     * @param flowId
     *          id of the process instance, cannot be null.
     * @param groupId
     *          id of the group to use as candidate, cannot be null.
     * @throws ActivitiObjectNotFoundException
     *           when the task or group doesn't exist.
     *//*

    void addParticipantGroup(long flowId, String groupId);

    */
/**
     * Convenience shorthand for {@link #deleteUserIdentityLink(String, String, String)}; with type {@link IdentityLinkType#CANDIDATE}
     *
     * @param flowId
     *          id of the process instance, cannot be null.
     * @param userId
     *          id of the user to use as candidate, cannot be null.
     * @throws ActivitiObjectNotFoundException
     *           when the task or user doesn't exist.
     *//*

    void deleteParticipantUser(long flowId, String userId);

    */
/**
     * Convenience shorthand for {@link #deleteGroupIdentityLink(String, String, String)}; with type {@link IdentityLinkType#CANDIDATE}
     *
     * @param flowId
     *          id of the process instance, cannot be null.
     * @param groupId
     *          id of the group to use as candidate, cannot be null.
     * @throws ActivitiObjectNotFoundException
     *           when the task or group doesn't exist.
     *//*

    void deleteParticipantGroup(long flowId, String groupId);

    */
/**
     * Removes the association between a user and a process instance for the given identityLinkType.
     *
     * @param flowId
     *          id of the process instance, cannot be null.
     * @param userId
     *          id of the user involve, cannot be null.
     * @param identityLinkType
     *          type of identityLink, cannot be null (@see {@link IdentityLinkType}).
     * @throws ActivitiObjectNotFoundException
     *           when the task or user doesn't exist.
     *//*

    void deleteUserIdentityLink(long flowId, String userId, String identityLinkType);

    */
/**
     * Removes the association between a group and a process instance for the given identityLinkType.
     *
     * @param flowId
     *          id of the process instance, cannot be null.
     * @param groupId
     *          id of the group to involve, cannot be null.
     * @param identityLinkType
     *          type of identity, cannot be null (@see {@link IdentityLinkType}).
     * @throws ActivitiObjectNotFoundException
     *           when the task or group doesn't exist.
     *//*

    void deleteGroupIdentityLink(long flowId, String groupId, String identityLinkType);

    */
/**
     * Retrieves the {@link IdentityLink}s associated with the given process instance. Such an {@link IdentityLink} informs how a certain user is involved with a process instance.
     *//*

    List<IdentityLink> getIdentityLinksForProcessInstance(String instanceId);


    */
/**
     * Suspends the process instance with the given id.
     * 挂起 暂停
     * If a process instance is in state suspended, activiti will not execute jobs (timers, messages) associated with this instance.
     *
     * If you have a process instance hierarchy, suspending one process instance form the hierarchy will not suspend other process instances form that hierarchy.
     *
     * @throws ActivitiObjectNotFoundException
     *           if no such processInstance can be found.
     * @throws ActivitiException
     *           the process instance is already in state suspended.
     *//*

    void suspendProcessInstanceById(long flowId);

    */
/**
     * Activates the process instance with the given id.
     * 激活 启动暂停的流程
     * If you have a process instance hierarchy, suspending one process instance form the hierarchy will not suspend other process instances form that hierarchy.
     *
     * @throws ActivitiObjectNotFoundException
     *           if no such processInstance can be found.
     * @throws ActivitiException
     *           if the process instance is already in state active.
     *//*

    void activateProcessInstanceById(long flowId);

    // Events
    // ////////////////////////////////////////////////////////////////////////

    */
/**
     * Adds an event-listener which will be notified of ALL events by the dispatcher.
     *
     * @param listenerToAdd
     *          the listener to add
     *//*

    void addEventListener(ActivitiEventListener listenerToAdd);

    */
/**
     * Adds an event-listener which will only be notified when an event occurs, which type is in the given types.
     *
     * @param listenerToAdd
     *          the listener to add
     * @param types
     *          types of events the listener should be notified for
     *//*

    void addEventListener(ActivitiEventListener listenerToAdd, ActivitiEventType... types);

    */
/**
     * Removes the given listener from this dispatcher. The listener will no longer be notified, regardless of the type(s) it was registered for in the first place.
     *
     * @param listenerToRemove
     *          listener to remove
     *//*

    void removeEventListener(ActivitiEventListener listenerToRemove);

    */
/**
     * Dispatches the given event to any listeners that are registered.
     *  触发调用事件
     * @param event
     *          event to dispatch.
     *
     * @throws ActivitiException
     *           if an exception occurs when dispatching the event or when the {@link ActivitiEventDispatcher} is disabled.
     * @throws ActivitiIllegalArgumentException
     *           when the given event is not suitable for dispatching.
     *//*

    void dispatchEvent(ActivitiEvent event);

    */
/**
     * 特别子流程:在特别子流程的容器中可以存放多个流程节点，这些节点在运行前不存在流程顺序，流程的顺序和执行，由执行时决定
     * 在流程配置中已经先配置好了流程节点,但没有流程顺序,和执行条件, 根据任务逻辑动态判断组合这些 特别子流程 行成一个逻辑流程
     *
     * Gets enabled activities from ad-hoc sub process
     * 得到激活的 特别子流程 节点列表
     * @param executionId
     *          id of the execution that has an ad-hoc sub process as current flow element
     * @return a list of enabled activities
     *//*

    List<FlowNode> getEnabledActivitiesFromAdhocSubProcess(String executionId);

    */
/**
     * Executes an activity in a ad-hoc sub process
     * 特别子流程:在特别子流程的容器中可以存放多个流程节点，这些节点在运行前不存在流程顺序，流程的顺序和执行，由执行时决定
     *
     * 让执行流到达第X个任务
     * @param executionId
     *          id of the execution that has an ad-hoc sub process as current flow element
     * @param activityId
     *          id of the activity id to enable
     * @return the newly created execution of the enabled activity
     *//*

    Execution executeActivityInAdhocSubProcess(String executionId, String activityId);

    */
/**
     * Completes the ad-hoc sub process
     * 完成特别子流程
     * @param executionId
     *          id of the execution that has an ad-hoc sub process as current flow element
     *//*

    void completeAdhocSubProcess(String executionId);

    */
/** The all events related to the given Process Instance. *//*

    List<Event> getProcessInstanceEvents(long flowId);
*/

}
